// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import html2canvas from 'html2canvas'
import store from './vuex'
import axios from 'axios'
console.log(store);
import _ from 'lodash'

// console.log(html2canvas)

Vue.prototype.myHtml2canvas = html2canvas

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  axios.get('../static/version.json?_=' + Math.random()).then(response => {
    if (200 == response.status) {
      if (process.env.VERSION !== response.data.version) {

        var message = "系统版本有更新，点击确认加载最新，或按【CTRL + F5】！"
        Vue.prototype.$alert(message, '系统提示', {
          confirmButtonText: '确定',
          callback: function(){
            window.location.reload(true);
          }
        });

        return;
      }
      next();
    }
  }).catch(err => {
    console.error(err);
    next();
  });
});


/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  components: { App },
  template: '<App/>'
})
